﻿/*#
# Copyright 2012 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This code is not supported by Google
#
*/

/**
 * Sample code to issue a simple GCS query using the Beta Google Client Libraries:
 * http://code.google.com/p/google-api-dotnet-client/
 * This code and the libraries above is NOT supported by Google Enterprise.   
 *  <Reference Include=Google.Apis: Google.Apis.dll
 *  <Reference Include=Google.Apis.Shopping.v1=Google.Apis.Shopping.v1.dll</HintPath>
 *  <Reference Include=Newtonsoft.Json.Net35=Newtonsoft.Json.Net35.dll
 *  (included in the library and samples on the .NET client above)    
 */

﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;

using Google.Apis.Shopping.v1;
using Google.Apis.Shopping.v1.Data;

namespace GCSSearch
{
    class GCSSearch
    {
        static void Main(string[] args)
        {
            var service = new ShoppingService { Key = "YOUR_KEY" };
            string query = "Camera";
            var request = service.Products.List("cx:YOUR_CX");
            request.Q = query;
            request.Country = "us";
            request.Language = "en";
            request.StartIndex = 1;
            request.MaxResults= 10;
            request.Safe = false;
            request.SpellingEnabled = true;
            request.SpellingUseGcsConfig = true;
            request.PromotionsEnabled = true;
            request.PromotionsUseGcsConfig = true;
            request.RedirectsEnabled = true;
            request.RelatedQueriesUseGcsConfig = true;
            request.FacetsEnabled = true;
            request.FacetsUseGcsConfig = true;

            Products response = request.Fetch();
            foreach (Product item in response.Items)
            {
                Console.WriteLine(item.ProductValue.Title);
            }

            Console.ReadKey();
        }
    }
}


